﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

namespace LabMS.Web.BaseData
{
    public partial class AddClassChooseMajor : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataBinds();
            }
        }

        protected void DataBinds()
        {
            Gv_DataBind();
        }

        protected void Gv_DataBind()
        {
            LabMS.BLL.Professional Pro = new LabMS.BLL.Professional();
            List<LabMS.Model.Professional> ls = Pro.GetModelList(CombineStr());
            Gv_Pro.DataSource = ls;
            Gv_Pro.DataBind();


        }
        protected string CombineStr()
        {
            string sqlWhere = "";
            if (!string.IsNullOrEmpty(tb_Code.Text.Trim()))
            {
                sqlWhere += " Pro_Code like '%" + tb_Code.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(tb_Name.Text.Trim()) && !string.IsNullOrEmpty(sqlWhere))
            {
                sqlWhere += " and ";
                sqlWhere += " Pro_Name='%" + tb_Name.Text.Trim() + "%'";
            }
            else if (!string.IsNullOrEmpty(tb_Name.Text.Trim()))
            {
                sqlWhere += " Pro_Name='%" + tb_Name.Text.Trim() + "%'";
            }
            return sqlWhere;

        }

        protected void Search_Click(object sender, EventArgs e)
        {
            Gv_DataBind();
        }

        protected void Reset_Click(object sender, EventArgs e)
        {
            tb_Code.Text = "";
            tb_Name.Text = "";
            Gv_DataBind();
        }

        protected void Gv_Pro_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            Gv_Pro.PageIndex = e.NewPageIndex;
            Gv_DataBind();
        }

        protected void Gv_Pro_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#003399'");
                //e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");
                e.Row.Attributes["style"] = "Cursor:pointer";
                e.Row.Attributes.Add("OnDblClick", "DbClickEvent('" + e.Row.Cells[1].Text + "','" + e.Row.Cells[3].Text + "')");
            }
        }
    }
}
